/**
 * 
 */
package org.skyeye.modeling.ui;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.skyeye.modeling.images.ImageInfo;
import org.skyeye.modeling.images.ImageProviderMapper;

/**
 * @author Vivian
 * @date 2017-7-4
 */
public class CustButton extends Button{

	public CustButton(Composite parent, int style) {
		super(parent, style|SWT.WRAP);
		checkSubclass();
		this.addSelectionListener(new SelectionListener() {
			
			@Override
			public void widgetSelected(SelectionEvent e) {
				Object data = CustButton.this.getData();
//				if (data == null) {
					if ((data instanceof String) && "0".equals(data)) {
						CustButton.this.setImage(ImageProviderMapper
								.getImage(ImageInfo.BLUE));
						CustButton.this.setData("1");
					}else if((data instanceof String) && "1".equals(data)){
						CustButton.this.setImage(ImageProviderMapper
								.getImage(ImageInfo.YELLOW));
						CustButton.this.setData("2");
					}else if((data instanceof String) && "2".equals(data)){
						CustButton.this.setImage(ImageProviderMapper
								.getImage(ImageInfo.WHITE));
						CustButton.this.setData("3");
					}else if((data instanceof String) && "3".equals(data)){
						CustButton.this.setImage(ImageProviderMapper
								.getImage(ImageInfo.RED));
						CustButton.this.setData("0");
					}
//				}else {
					
//				}
			}
			
			@Override
			public void widgetDefaultSelected(SelectionEvent e) {
				
			}
		});
		
		setImage(ImageProviderMapper.getImage(ImageInfo.WHITE));
		setData("3");
	}
	
	protected void checkSubclass() {

	}

	
	
	

}
